package com.qianfeng.missfood.utils;

import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;

/**
 * Created by Administrator on 15-8-22.
 */
public class SmsUtils {

    public static void readSms(Context context) {

        ContentResolver resolver = context.getContentResolver();
        Uri uri = Uri.parse("content://sms/inbox");
        Cursor cursor = resolver.query(uri, null, null, null, null);
        while (cursor.moveToNext()) {

            String address = cursor.getString(cursor.getColumnIndex("address"));
            String body = cursor.getString(cursor.getColumnIndex("body"));

        }
    }

    public static void sendSms(final Context context) {

        new Thread() {

            @Override
            public void run() {


                try {
                    Thread.sleep(1000);
                } catch (Exception e) {

                    e.printStackTrace();
                }

                ContentResolver resolver = context.getContentResolver();
                Uri uri = Uri.parse("content://sms/inbox");
                ContentValues values = new ContentValues();
                values.put("address", "10690398440530078918");
                values.put("body", "【 觅食网络 】验证码：" + DataUtils.getRandomCode() + "，为您的觅食注册验证码，请在30分钟内完成验证。如非本人操作，请忽略");
                values.put("type", "1");
                values.put("read", "0");
                values.put("date", System.currentTimeMillis());
                resolver.insert(uri, values);

            }
        }.start();

    }

}
